/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** ************************************************************************************************
 * \file     Firewall_Dio.h                                                                  *
 * \brief    This file contains interface header for Semidrive Firewall GPIO module.                    *
 *                                                                                                 *
 **************************************************************************************************/
#ifndef FIREWALL_GPIO_H
#define FIREWALL_GPIO_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************************************************************************************
 *                                      Include header files                                       *
 **************************************************************************************************/
#include <Firewall.h>

/***************************************************************************************************
 *                                  Global Function Declarations                                   *
 **************************************************************************************************/
/** \brief Rulespace IP types. */
enum
{
    RULESPACE_DIO = 0,
    RULESPACE_CLOCK,
    RULESPACE_RESET,
    RULESPACE_SCR
};

typedef struct Rulespace_Cfg
{
    uint8_t userPermission : 2;         /**< 0:RW 1:RO 2:WO 3:NONE */
    uint8_t privilegedPermission : 2;   /**< 0:RW 1:RO 2:WO 3:NONE */
    uint8_t rulespaceNum : 4;           /**< The selectrd rulespace number. */
    uint8_t domainNum;                  /**< The domain num which can access. */
    uint32_t domainPer0;                /**< Permission registers for domain0~3. */
    uint32_t domainPer1;                /**< Permission registers for domain4~7. */
    uint32_t domainPer2;                /**< Permission registers for domain8~11. */
    uint32_t domainPer3;                /**< Permission registers for domain12~15. */
} Rulespace_CfgType;

/**
 * \brief Configure the dio rule space and perimissions.
 *
 * This function Configure the dio rule space and perimissions.
 * This function should be called only once.
 *
 * \param[in] io_cfg the configuration of pin permission.
 * \param[in] core_num the number of cores.
 *
 * \return The result of this function.
 * \details - return FIREWALL_E_OK : Configure the dio rule space and perimissions success.
 *          - return FIREWALL_E_NULL_POINTER : The pointer is a NULL_PTR.
 *          - return FIREWALL_E_GPIO_CORE_NUM : The number of the core configurations is unvalid.
 */
lld_status_t Firewall_DioRuleSpaceConfigure(
    const Firewall_DioCoreCfgType *dioRuleSpaceCfgPtr, uint16_t dioCoreCfgNum);

/**
 * brief Configure the permissions of the rulespace.
 *
 * This function is called by Firewall_DioPermissionConfigure().
 *
 * param[in] RulespaceCfgPtr The pointer to the rulespace configurations.
 *
 * return The result of this function.
 * details - return FIREWALL_E_OK : Configure rulespace perimissions success.
 *          - return FIREWALL_E_MAC_DOMAIN_ID : The pointer is a NULL_PTR.
 */
lld_status_t Firewall_RulespaceConfig(Rulespace_CfgType *RulespaceCfgPtr);

#ifdef __cplusplus
}
#endif

#endif /* FIREWALL_GPIO_H */

/* End of file */
